//
//  BaseViewController.m
//  GiftThat
//
//  Created by ChuXiang on 16/1/6.
//  Copyright © 2016年 ChuXiang. All rights reserved.
//

#import "BaseViewController.h"

@interface BaseViewController ()

@end

@implementation BaseViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];

    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:255 / 255.0 green:38 / 255.0 blue:56 / 255.0 alpha:1.0];
    self.navigationController.navigationBarHidden = NO;
    self.navigationController.navigationBar.translucent = NO;
    
    [self.navigationController.navigationBar setTitleTextAttributes:
     @{NSFontAttributeName:[UIFont fontWithName:@"FZLanTingHei-EL-GBK" size:20],NSForegroundColorAttributeName:[UIColor whiteColor]}];
    
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    [center addObserver:self selector:@selector(changeDay:) name:@"Color" object:nil];
    
    
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"Color"] isEqualToString:@"GreenColor"]) {
        self.navigationController.navigationBar.barTintColor  = [UIColor greenColor];
        self.tabBarController.tabBar.barTintColor = [UIColor whiteColor];

        
    }else if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"Color"] isEqualToString:@"OrangeColor"]) {
        self.navigationController.navigationBar.barTintColor  = [UIColor orangeColor];
        self.tabBarController.tabBar.barTintColor = [UIColor whiteColor];


    }else if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"Color"] isEqualToString:@"PinkColor"]) {
        self.navigationController.navigationBar.barTintColor  = [UIColor colorWithRed:238 / 255.0 green:61 / 255.0 blue: 89 / 255.0 alpha:1.0];
        self.tabBarController.tabBar.barTintColor = [UIColor whiteColor];

        
    }else if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"Color"] isEqualToString:@"BlackColor"]) {
        self.navigationController.navigationBar.barTintColor  = [UIColor blackColor];
        self.tabBarController.tabBar.barTintColor = [UIColor blackColor];
    }else{

        self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:255 / 255.0 green:38 / 255.0 blue:56 / 255.0 alpha:1.0];
        self.tabBarController.tabBar.barTintColor = [UIColor whiteColor];

        
    }

    
}

- (void) changeDay:(NSNotification *)message {
    if ([message.object isEqualToString:@"RedColor"]) {
        self.navigationController.navigationBar.barTintColor  = [UIColor colorWithRed:255 / 255.0 green:38 / 255.0 blue:56 / 255.0 alpha:1.0];
        self.tabBarController.tabBar.barTintColor = [UIColor whiteColor];

        
    }else if([message.object isEqualToString:@"GreenColor"]) {
        self.navigationController.navigationBar.barTintColor  = [UIColor greenColor];
        self.tabBarController.tabBar.barTintColor = [UIColor whiteColor];

        
    }else if([message.object isEqualToString:@"OrangeColor"]) {
        self.navigationController.navigationBar.barTintColor  = [UIColor orangeColor];
        self.tabBarController.tabBar.barTintColor = [UIColor whiteColor];

        
    }else if([message.object isEqualToString:@"PinkColor"]) {
        self.navigationController.navigationBar.barTintColor  = [UIColor colorWithRed:238 / 255.0 green:61 / 255.0 blue: 89 / 255.0 alpha:1.0];
        self.tabBarController.tabBar.barTintColor = [UIColor whiteColor];

    }else {
        self.navigationController.navigationBar.barTintColor = [UIColor blackColor];
        self.tabBarController.tabBar.barTintColor = [UIColor blackColor];

    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
